package org.dtrd.modules.record.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.common.util.DateUtils;
import org.dtrd.modules.record.entity.bean.MedicalRecordInfo;

import java.util.Date;


/**
 * <p>
 * 用药记录
 * </p>
 *
 * @author QR
 * @since 2021-12-06
 */
@Getter
@Setter
@TableName("dtrd_ent_rd_signin_medical_record")
public class DtrdEntRdSigninMedicalRecord {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    @TableField("patient_id")
    private Integer patientId;

    /**
     * 药品库的药品Id
     */
    @TableField("drug_id")
    private Integer drugId;

    /**
     * 记录日期
     */
    @TableField("record_date")
    private Date recordDate;

    /**
     * 用药时间
     */
    @TableField("record_time")
    private Date recordTime;

    /**
     * 照片以 竖线 | 拼接
     */
    @TableField("medical_record_photo")
    private String medicalRecordPhoto;

    /**
     * 服用药品描述
     */
    @TableField("medical_record_describe")
    private String medicalRecordDescribe;

    /**
     * 1-早,2-午,3-晚,4-睡前
     */
    @TableField("medical_record_type")
    private Integer medicalRecordType;

    @TableField("medical_record_status")
    private Integer medicalRecordStatus;

    /**
     * 用药规格
     */
    @TableField("medical_spec")
    private String medicalSpec;

    /**
     * 用法用量
     */
    @TableField("medical_use_mode")
    private String medicalUseMode;

    /**
     * 档案标记1-建档,0-日常监测
     */
    @TableField("medical_record_archive_tag")
    private String medicalRecordArchiveTag;

    /**
     * 备注
     */
    @TableField("medical_record_remark")
    private String medicalRecordRemark;

    @TableField("create_time")
    private Date createTime;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    public DtrdEntRdSigninMedicalRecord init() {
        createTime = new Date();
        isDel = 0;
        return this;
    }

    public DtrdEntRdSigninMedicalRecord parseFromDto(MedicalRecordInfo dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        drugId = dto.getDrugId();
        Date date = DateUtils.getDate(dto.getRecordTime());
        if (date != null) {
            recordDate = date;
        }
        recordTime = dto.getRecordTime();
        medicalRecordPhoto = dto.getMedicalRecordPhoto();
        medicalRecordDescribe = dto.getMedicalRecordDescribe();
        medicalRecordType = dto.getMedicalRecordType();
        medicalSpec = dto.getMedicalSpec();
        medicalUseMode = dto.getMedicalUseMode();
        medicalRecordRemark = dto.getMedicalRecordRemark();
        medicalRecordStatus = dto.getMedicalRecordStatus();
        return this;
    }


}
